home *** CD-ROM | disk | FTP | other *** search
- #include "DemoRoutines.h"
-
- long GWGet32PixelAsm( GWorldPtr src, short x, short y )
- {
- PixMapHandle srcPixMap;
- unsigned short srcRowBytes;
- long srcBaseAddr;
- long srcAddr;
- char mmuMode;
- long result;
-
- srcPixMap = GetGWorldPixMap( src );
- srcBaseAddr = (long) GetPixBaseAddr ( srcPixMap ); /* get the address of the pixmap */
- mmuMode = true32b;
- SwapMMUMode ( &mmuMode ); /* set the MMU to 32-bit mode */
-
- asm {
- move.l srcPixMap,a0
- move.l srcBaseAddr,a1
- move.l (a0),a0 ;get ptr to pixmap
- move.w y,d1 ;get y
- sub.w 6(a0),d1 ;make y bounds 0 relative
- move.w 4(a0),d0 ;get rowbytes
- and.w #0x7FFF,d0 ;strip bitmap/pixmap bit
- mulu.w d0,d1 ;calculate offset to beginning of this row
- adda.l d1,a1 ;calculate address of this row
- moveq #0,d0 ;extend x to a word
- move.w x,d0
- sub.w 8(a0),d0 ;make x bounds 0 relative
- lsl.w #2,d0 ;convert x to pixels (4 bytes/pixel)
- adda.l d0,a1 ;calculate pixel address
- move.l (a1),result
- }
- SwapMMUMode ( &mmuMode ); /* restore the previous MMU mode */
- return( result );
- }
-
- void GWSet32PixelAsm( GWorldPtr src, short x, short y, long pixelValue )
- {
- PixMapHandle srcPixMap;
- unsigned short srcRowBytes;
- long srcBaseAddr;
- long srcAddr;
- char mmuMode;
-
- srcPixMap = GetGWorldPixMap( src );
- srcBaseAddr = (long) GetPixBaseAddr ( srcPixMap ); /* get the address of the pixmap */
- mmuMode = true32b;
- SwapMMUMode ( &mmuMode ); /* set the MMU to 32-bit mode */
-
- asm {
- move.l srcPixMap,a0
- move.l srcBaseAddr,a1
- move.l (a0),a0 ;get ptr to pixmap
- move.w y,d1 ;get y
- sub.w 6(a0),d1 ;make y bounds 0 relative
- move.w 4(a0),d0 ;get rowbytes
- and.w #0x7FFF,d0 ;strip bitmap/pixmap bit
- mulu.w d0,d1 ;calculate offset to beginning of this row
- adda.l d1,a1 ;calculate address of this row
- moveq #0,d0 ;extend x to a word
- move.w x,d0
- sub.w 8(a0),d0 ;make x bounds 0 relative
- lsl.w #2,d0 ;convert x to pixels (4 bytes/pixel)
- adda.l d0,a1 ;calculate pixel address
- move.l pixelValue,(a1)
- }
- SwapMMUMode ( &mmuMode ); /* restore the previous MMU mode */
- }
-
- /*
- ** The "Fast" versions of the calls assume they are called in 32-bit addressing mode.
- ** The PixMapPtr and srcBaseAddr must be 32-bit clean.
- */
-
- long FastGWGet32Pixel( PixMap *srcPixMap, long *srcBaseAddr, short x, short y )
- {
- long result;
-
- asm {
- move.l srcPixMap,a0 ;must be 32-bit clean pointer
- move.w y,d1 ;get y
- sub.w 6(a0),d1 ;make y bounds 0 relative
- move.w 4(a0),d0 ;get rowbytes
- and.w #0x7FFF,d0 ;strip bitmap/pixmap bit
- mulu.w d0,d1 ;calculate offset to beginning of this row
- move.l srcBaseAddr,a1 ;must be 32-bit base address
- adda.l d1,a1 ;calculate address of this row
- moveq #0,d0 ;extend x to a word
- move.w x,d0
- sub.w 8(a0),d0 ;make x bounds 0 relative
- lsl.w #2,d0 ;convert x to pixels (4 bytes/pixel)
- adda.l d0,a1 ;calculate pixel address
- move.l (a1),result
- }
- return( result );
- }
-
- void FastGWSet32Pixel( PixMap *srcPixMap, long *srcBaseAddr, short x, short y, long pixelValue )
- {
-
- asm {
- move.l srcPixMap,a0 ;must be 32-bit clean pointer
- move.w y,d1 ;get y
- sub.w 6(a0),d1 ;make y bounds 0 relative
- move.w 4(a0),d0 ;get rowbytes
- and.w #0x7FFF,d0 ;strip bitmap/pixmap bit
- mulu.w d0,d1 ;calculate offset to beginning of this row
- move.l srcBaseAddr,a1 ;must be 32-bit base address
- adda.l d1,a1 ;calculate address of this row
- moveq #0,d0 ;extend x to a word
- move.w x,d0
- sub.w 8(a0),d0 ;make x bounds 0 relative
- lsl.w #2,d0 ;convert x to pixels (4 bytes/pixel)
- adda.l d0,a1 ;calculate pixel address
- move.l pixelValue,(a1)
- }
- }
-
-